
; FASM SOURCE FILE
; http://flatassembler.net

; Data Types

; written by @L.CHEMIST (Andrey A. Meshkov)
; http://maalchemist.narod.ru
; maalchemist@yandex.ru
; maalchemist@gmail.com

; ------------------------------------------------------------------------------

; Tomasz Grysztar

; macro typedef type, base
; { struc type [v] \{ \common . base v \}
;   macro type [v] \{ \common base v \} }

; typedef long, dd
; typedef DWORD, long

; macro typedef statement
; { match base type, statement
;   \{ struc type [v] \\{ \\common . base v \\}
;      macro type [v] \\{ \common base v \\} \} }

; typedef dd long
; typedef long DWORD

; ------------------------------------------------------------------------------

macro TYPEDEF type, base {
  restruc type
  purge type

  struc type [v] \{ \common . base v \}
  macro type [v] \{ \common base v \}

  virtual at 0
  local label, sizeof
    label type ?
    sizeof = $ - label
    sizeof.#type = sizeof
  end virtual
}

macro _TYPEDEF_WIN64 TYPE, BASE64, BASE32 {
  TYPEDEF TYPE, BASE32
  match =TRUE, _WIN64 \{ TYPEDEF TYPE, BASE64 \}
}

macro TYPEDEF_WIN64 TYPE, BASE64, BASE32 {
  match =TRUE,  _WIN64 \{ TYPEDEF TYPE, BASE64 \}
  match =FALSE, _WIN64 \{ TYPEDEF TYPE, BASE32 \}
}

macro TYPEDEF_X64 TYPE, BASE64, BASE32 {
  match =TRUE,  _X64 \{ TYPEDEF TYPE, BASE64 \}
  match =FALSE, _X64 \{ TYPEDEF TYPE, BASE32 \}
}

macro _TYPEDEF_UNICODE TYPE, WBASE, ABASE {
  TYPEDEF TYPE, ABASE
  match =TRUE, UNICODE \{ TYPEDEF TYPE, WBASE \}
}

macro TYPEDEF_UNICODE TYPE, WBASE, ABASE {
  match =TRUE,  UNICODE \{ TYPEDEF TYPE, WBASE \}
  match =FALSE, UNICODE \{ TYPEDEF TYPE, ABASE \}
}

macro TYPEDEF_X64_EQU TYPE, BASE64, BASE32 {
    match =TRUE,  _X64 \{ TYPE equ BASE64 \}
    match =FALSE, _X64 \{ TYPE equ BASE32 \}
}

; ------------------------------------------------------------------------------

macro VIRTDEF vtype, type {
  virtual at 0
    vtype type ?
  end virtual
}

; ------------------------------------------------------------------------------

macro PADDING x64, x86 {
  match =TRUE,  _X64 \{ rept x64 \\{ db ? \\} \}
  match =FALSE, _X64 \{ rept x86 \\{ db ? \\} \}
}